package com.kermel.andromeda.activities.dbtool.manage;

import com.kermel.andromeda.R;
import com.kermel.andromeda.data.persistence.AndromedaDatabaseManager;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

public class DatabaseManagementActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.manage);
        
        View deleteDBButton = findViewById(R.id.deleteDBButton);
        if (deleteDBButton != null)
            deleteDBButton.setOnClickListener(new DeleteDatabaseAction());
        
        View initializeDBButton = findViewById(R.id.initializeDBButton);
        if (initializeDBButton != null)
            initializeDBButton.setOnClickListener(new InitializeDatabaseAction());
        
    }
    
    private void initializeDatabase() {
        AndromedaDatabaseManager.instance.initializeDatabase(this);
    }
    
    private class DeleteDatabaseAction implements OnClickListener {
        public void onClick(View v) {
            AndromedaDatabaseManager.instance.deleteDatabase();
        }
    }
    
    private class InitializeDatabaseAction implements OnClickListener {
        public void onClick(View v) {
            initializeDatabase();
        }
    }
}
